<?php
// 修改一条优惠券
require $this->website['path']['action'] . '/admin/isadmin.php';

$json = array('status' => 'error', 'msg' => '', 'data' => '');

$uid = $admin['id'];
$id = fn_post('id');
$data = fn_post('data');

$arr = json_decode($data, 1);

if (!$this->website['class']['db']
	->table('product_order')
	->where('id=?', $id)
	->limit(1)
	->count()) {
	$json['msg'] = '订单未找到';
} else {
	$field = array_keys($arr);
	$field[] = 'uid';
	$value = array_values($arr);
	$value[] = $uid;
	$id = $this->website['class']['db']
		->table('product_order')
		->field($field)
		->value($value)
		->where('id=?', $id)
		->limit(1)
		->update();
	// $json['sql'] = $this->website['class']['db']->sql;
	if ($id) {
		$json['status'] = 'ok';
		$json['msg'] = '订单修改成功!';
	} else {
		$json['msg'] = '订单修改失败!';
	}
}

$this->json_encode($json);